package com.yym.duotai;

import jdk.nashorn.internal.ir.CallNode;
/*
使用父类作为形参进而实现多态，使方法的参型更加广泛
 */
public class testBasic02 {
    public static void main(String[] args) {
        Car car = new Car();
        car.type = "小汽车";
        car.speed = 44434;
        car.brand = "wewe";
        car.run();
        Vechicle vechicle = new Car();//父类引用指向子类对象
        vechicle.type = "sad";
        vechicle.speed = 54;
        vechicle.price = 255.22;
        vechicle.run();//如果有的话调用子类的方法，没有的话调用父类
        Bus bus = new Bus();
        bus.type="sds";
        bus.speed=54;
        bus.price=34;
        Employee employee = new Employee();
        employee.name="tom";
//        employee.goHome(bus);
//        Bicycle bicycle = new Bicycle();
//        bicycle.price=1000.00;
//        employee.goHome(bicycle);
        //----
       // employee.goHome();
    }
    }
    class Employee{
    String name;
    //回家
        public void goHome(Vechicle vechicle){
            System.out.println(name+"正在乘车");
vechicle.run();
        }
    }
  class Vechicle{
        String type;
        int speed;
        double price;
        public void run() {
            System.out.println("一俩兼职" + price + "rev的" + type + "正在用" + speed + "速度");

        }
    }
class Car extends  Vechicle{
        String brand;
    }
   class Bus extends  Vechicle {
       int seatNum;

       public void run() {
           System.out.println("一俩兼职" + price + "rev的" + type + "正在用" + speed + "速度");
       }
   }
 class Bicycle extends Vechicle{
     public void run() {
         System.out.println("一俩兼职" + price + "rev的" + type + "正在用" + speed + "速度");
     }
}
